package com.yk.faceapplication.util;

import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class FormatUtil {
	private static String beforeAmount = "";
	/**
	 * @param d
	 * @return
	 */
	public static String formatDouble(double d) {
        DecimalFormat df = new DecimalFormat("#.00");
        return df.format(d);
    }

    public static double formatDouble2(double d) {
        return (double)Math.round(d*100)/100;
    }

    public static Long string2Long(String data){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date date = (Date) sdf.parse(data);
            return date.getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0l;
    }

    
    public static String long2String(long time){
    	SimpleDateFormat sdf= new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    	//前面的lSysTime是秒数，先乘1000得到毫秒数，再转为java.util.Date类型
    	Date dt = new Date(time);
    	String sDateTime = sdf.format(dt);  //得到精确到秒的表示：08/31/2006 21:08:00
    	return sDateTime;
    }

    public static String getYMD(String time){
        return time.split(" ")[0];
    }



}
